{extend name="public:_base" /}
{block name="css"}
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/uploadify/uploadify.css">
{/block}
{block name="js"}
{include file="public/_validform"}

<!-- 下载文件 -->
<script src="__STATIC__/admin/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/upfile.js" type="text/javascript"></script>

<script type="text/javascript">
    var URL = {
        uploader: "{:url('Upload/image')}",
        swf: "__STATIC__/admin/uploadify/uploadify.swf",
        ROOT: "__PUBLIC__/uploads/image",
    }

    var array = [{$data.type ?? ''}];
    for (var k = 0, length = array.length; k < length; k++) {
        $("[name='nav_id[]'][value=\'" + array[k] + "\']").attr("checked", true);
    }

    function checkAll(obj) {
        $(obj).parents('.b-group').eq(0).find("input[type='checkbox']").prop('checked', $(obj).prop('checked'));
    }
    upload_image('image','','473','327','300');
    upload_image('code','','200','200','300');
</script>
{/block}
{block name="main"}

<div class="page-container">
    
    <form action="{:url(\''.\\think\\Request::instance()->controller().'/save')}" method="post" class="form form-horizontal" id="form">
        
        <table class="table table-border table-bordered table-bg table-style">
            <thead>
                <tr>
                    <th colspan="2" scope="col">填写信息</th>
                </tr>
            </thead>
            
            <tbody>
                <tr>
                    <th>
                        <span class="c-red">*</span>图片473 * 327：
                    </th>
                    <td>
                        <div id="image_s">
                            <a href="__PUBLIC__/uploads/{$data.image ?'image/'.$data.image: 'sm_172.jpg'}" target="_blank">
                                <img src="__PUBLIC__/uploads/{$data.image ?'image/'.$data.image: 'sm_172.jpg'}" width="473px" height="327px" />
                            </a>
                        </div>
                        <input class="input-text" name="image" type="hidden" id="image_post" value="{$data.image ?? ''}"/>
                        <input class="input-text" name="old_image" type="hidden" value="{$data.image ?? ''}"/>
                        <input id="image" name="file_upload" type="file" multiple="true">
                    </td>
                </tr>
                <tr>
                    <th>
                        <span class="c-red">*</span>二维码200*200:
                    </th>
                    <td>
                        <div id="code_s">
                            <a href="__PUBLIC__/uploads/{$data.code ?'image/'.$data.code: 'sm_200.jpg'}" target="_blank">
                                <img src="__PUBLIC__/uploads/{$data.code ?'image/'.$data.code: 'sm_200.jpg'}" width="200px" height="200px" />
                            </a>
                        </div>
                        <input class="input-text" name="code" type="hidden" id="code_post" value="{$data.code ?? ''}"/>
                        <input class="input-text" name="old_code" type="hidden" value="{$data.code ?? ''}"/>
                        <input id="code" name="file_upload" type="file" multiple="true">
                    </td>
                </tr>
                
                <tr>
                    <th>
                        标题：
                    </th>
                    <td>
                        <input type="text" class="input-text" value="{$data.title ?? ''}" placeholder="" name="title">
                    </td>
                </tr>
                
                <tr>
                    <th>
                        链接：
                    </th>
                    <td>
                        <input id="file_size" type="url" class="input-text" value="{$data.url ?? ''}" placeholder="http://localhost/" name="url">
                    </td>
                </tr>
                
                <tr>
                    <th>
                        排序：
                    </th>
                    <td>
                        <input name="sort" type="number" class="input-text" placeholder="50" value="{$data.sort ?? '0' }">
                        <div style="font-size: 14px;float: left;margin: 5px 0 0 0;">
                            <span class="c-red">*</span>  不填写, 默认排序为最高
                        </div>
                    </td>
                </tr>
                
                <tr>
                    <th>
                        所属栏目：
                    </th>
                    <td>
                        <table class="table table-border table-bordered table-bg table-hover table-sort table-box">
                            <thead>
                                <tr class="text-c">
                                    <th>所有栏目  <input name="nav" type="checkbox"></th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr class="text-c">
                                    <td>
                                        {notempty name="nav"}
                                            {volist name="nav" id="vo"}
                                            <p class="che-box">
                                                <input id="{$vo.id}" name="nav_id[]" type="checkbox" value="{$vo.id}" >
                                                <label for="{$vo.id}">{$vo.level}{$vo.name}</label>
                                            </p>
                                            {/volist}
                                        {/notempty}
                                        <table class="table table-striped table-bordered table-condensed table-item">
                                            <tr class="b-group">
                                                <th width="10%">
                                                    <label>
                                                        首页
                                                        <input id="0" name="nav_id[]" type="checkbox" value="0" >
                                                    </label>
                                                </th>
                                                <td></td>
                                            </tr>
                                            {foreach name="auth_rule" item="v"}
                                            {empty name="v['child']"}
                                            <tr class="b-group">
                                                <th width="10%">
                                                    <label>
                                                        {$v['name']}
                                                        <input type="checkbox" name="nav_id[]" value="{$v['id']}"  onclick="checkAll(this)" >
                                                    </label>
                                                </th>
                                                <td></td>
                                            </tr>
                                            {else /}
                                            <tr class="b-group">
                                                <th width="10%">
                                                    <label>
                                                        {$v['name']}
                                                        <input type="checkbox" name="nav_id[]" value="{$v['id']}"  onclick="checkAll(this)">
                                                    </label>
                                                </th>
                                                <td class="b-child">
                                                    {foreach name="v['child']" item="n"}
                                                    <table class="table table-striped table-bordered table-hover table-condensed table-item-two">
                                                        <tr class="b-group">
                                                            <th width="10%">
                                                                <label>
                                                                    {$n['name']}
                                                                    <input type="checkbox" name="nav_id[]" value="{$n['id']}"  onclick="checkAll(this)">
                                                                </label>
                                                            </th>
                                                            <td class="bs-group">
                                                                {notempty name="n['child']"}
                                                                {volist name="n['child']" id="c"}
                                                                <label>
                                                                    &emsp;{$c['name']} <input type="checkbox" name="nav_id[]" value="{$c['id']}" >
                                                                </label>
                                                                {/volist}
                                                                {/notempty}
                                                            </td>
                                                        </tr>
                                                    </table>
                                                    {/foreach}
                                                </td>
                                            </tr>
                                            {/empty}
                                            {/foreach}
                                        </table>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </tbody>
            
            <tfoot>
                <tr>
                    <th></th>
                    <td>
                        {:token()}
                        <input type="hidden" value="{$data.id ?? ''}" name="id">
                        <input class="btn radius btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                        <input class="btn radius btn-default radius" type="reset" value="&nbsp;&nbsp;重置&nbsp;&nbsp;">
                        <!-- <button onClick="layer_close();" class="btn radius btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button> -->
                    </td>
                </tr>
            </tfoot>
            
        </table>

    </form>
</div>
{/block}
